package iscte.ai.kcgtd;

import java.io.Serializable;

public class PeriodStats implements Serializable{


	private static final long serialVersionUID = -2460416859833837595L;
	private String nome;
	private int points;
	private int projectosPoints;
	private int lazerPoints;
	private int comprasPoints;
	private int hora_inicio;
	private int hora_fim;
	private KCGTDTime duration;

	public PeriodStats(String nome, int hora_inicio, int hora_fim) {
		this.nome = nome;
		this.hora_inicio = hora_inicio;
		this.hora_fim = hora_fim;
		points = 0;
		projectosPoints = 0;
		lazerPoints = 0;
		comprasPoints = 0;
		
		int hour = hora_fim - hora_inicio;
		duration = new KCGTDTime();
		duration.setHour(hour);
		duration.setMinute(0);
		duration.setSecond(0);		
		
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public int getPoints() {
		return points;
	}

	public int getProjectosPoints() {
		return projectosPoints;
	}

	public int getLazerPoints() {
		return lazerPoints;
	}

	public int getComprasPoints() {
		return comprasPoints;
	}

	public int getHora_inicio() {
		return hora_inicio;
	}

	public int getHora_fim() {
		return hora_fim;
	}
	
	public KCGTDTime getDuration() {
		return duration;
	}
	
	public void incrementPoints(String type){
		points++;
		
		switch (type) {
			case MainActivity.CATEGORIA_PROJECTOS:
				projectosPoints++;
				break;
			case MainActivity.CATEGORIA_LAZER:
				lazerPoints++;
				break;
			case MainActivity.CATEGORIA_COMPRAS:
				comprasPoints++;
				break;
		}
	}
	
	public void decrementPoints(String type){
		points--;
		
		switch (type) {
			case MainActivity.CATEGORIA_PROJECTOS:
				projectosPoints--;
				break;
			case MainActivity.CATEGORIA_LAZER:
				lazerPoints--;
				break;
			case MainActivity.CATEGORIA_COMPRAS:
				comprasPoints--;
				break;
		}
	}
	
	public double getOverallPoints(String type){

		switch (type) {
			case MainActivity.CATEGORIA_PROJECTOS:
				return points * 0.3 + projectosPoints * 0.70;
			case MainActivity.CATEGORIA_LAZER:
				return points * 0.3 + lazerPoints * 0.70;
			case MainActivity.CATEGORIA_COMPRAS:
				return points * 0.3 + comprasPoints * 0.70;
		}

		return 0;
	}
	
	
	@Override
	public String toString() {
		return getNome();
	}
}
